package com.atguigu.gmall.Service.impl;

import com.atguigu.gmall.Service.OrderDetailService;
import com.atguigu.gmall.entity.OrderDetail;
import com.atguigu.gmall.mapper.OrderDetailMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class OrderDetailServiceImpl extends ServiceImpl<OrderDetailMapper,OrderDetail> implements OrderDetailService {
    @Override
    public List<OrderDetail> findOrderDetailBySkus(Long orderId, List<String> skuIdList) {
        List<OrderDetail> orderDetails = new ArrayList<>();
        for (String skuId : skuIdList) {
            QueryWrapper<OrderDetail> queryWrapper = new QueryWrapper<>();
            queryWrapper.eq("order_id", orderId).eq("sku_id", skuId);
            OrderDetail orderDetail = baseMapper.selectOne(queryWrapper);
            orderDetails.add(orderDetail);
        }
        return orderDetails;
    }
}
